home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / GameboyDev / GBDK / lib / strncmp.c < prev    next >
C/C++ Source or Header  |  1999-03-29  |  288b  |  19 lines

  1. #include <string.h>
  2.  
  3. /*
  4.  * Compare strings (at most n bytes):
  5.  *  s1>s2: >0
  6.  *  s1==s2: 0
  7.  *  s1<s2: <0
  8.  */
  9.  
  10. BYTE strncmp(const char *s1, const char *s2, UBYTE n)
  11. {
  12.   while(n > 0 && *s1 == *s2++) {
  13.     if(*s1++ == '\0')
  14.       return 0;
  15.     n--;
  16.   }
  17.   return (n == 0 ? 0 : *s1 - *--s2);
  18. }
  19.